Looking to recreate the date picker similar to the object properties of a date. I want a clear field unless the user choose to change the date. Any hints on how to start would be appreciated.
jobina - Wed Jan 13 10:36:44 EST 2016 |
Re: Date picker I made the following component that prompts the user to select a date. You can pass in Dates for: - init: the initial date displayed - min: the earliest date that can be selected (or null for no minimum) - max: the latest date that can be selected (or null for no maximum)
A little example of it's usage is at the end of the code (prints the selected date in DXL interaction window), though you could feed the date back into whatever GUI you're developing.
DB selectDateDlg
DBE selectDateLabelDBE
DBE selectDateDBE
DBE selectDateOkButton
bool selectDateDlgClosed = false
string dateSelectedByUser = null
void selectDateOnSelectCB(DB dlg)
{
dateSelectedByUser = get(selectDateDBE)
}
void selectDateOnCloseCB(DB dlg)
{
selectDateDlgClosed = true
release(dlg)
}
bool selectDateDialog(Date &selectedDate, string titleStr, string messageStr, Date init, Date min, Date max)
{
selectedDate = null
selectDateDlg = centred titleStr
selectDateLabelDBE = label(selectDateDlg, messageStr)
selectDateDBE = date(selectDateDlg, 30, init, true)
selectDateOkButton = ok(selectDateDlg, "Select", selectDateOnSelectCB)
close(selectDateDlg, true, selectDateOnCloseCB)
realize(selectDateDlg)
setLimits(selectDateDBE, min, max)
setSize(selectDateDlg, 300, 150)
block(selectDateDlg)
if (selectDateDlgClosed) return false
if (null(dateSelectedByUser)) return false
// user has selected a date
selectedDate = dateOnly(date(dateSelectedByUser, userLocale()))
return true
}
Date d
if (selectDateDialog(d, "Date Selector", "Please select a date:", today, null, null))
{
print stringOf(d)
}
|
Re: Date picker Antonio__Norkus - Wed Jan 13 11:33:18 EST 2016 I made the following component that prompts the user to select a date. You can pass in Dates for: - init: the initial date displayed - min: the earliest date that can be selected (or null for no minimum) - max: the latest date that can be selected (or null for no maximum)
A little example of it's usage is at the end of the code (prints the selected date in DXL interaction window), though you could feed the date back into whatever GUI you're developing.
DB selectDateDlg
DBE selectDateLabelDBE
DBE selectDateDBE
DBE selectDateOkButton
bool selectDateDlgClosed = false
string dateSelectedByUser = null
void selectDateOnSelectCB(DB dlg)
{
dateSelectedByUser = get(selectDateDBE)
}
void selectDateOnCloseCB(DB dlg)
{
selectDateDlgClosed = true
release(dlg)
}
bool selectDateDialog(Date &selectedDate, string titleStr, string messageStr, Date init, Date min, Date max)
{
selectedDate = null
selectDateDlg = centred titleStr
selectDateLabelDBE = label(selectDateDlg, messageStr)
selectDateDBE = date(selectDateDlg, 30, init, true)
selectDateOkButton = ok(selectDateDlg, "Select", selectDateOnSelectCB)
close(selectDateDlg, true, selectDateOnCloseCB)
realize(selectDateDlg)
setLimits(selectDateDBE, min, max)
setSize(selectDateDlg, 300, 150)
block(selectDateDlg)
if (selectDateDlgClosed) return false
if (null(dateSelectedByUser)) return false
// user has selected a date
selectedDate = dateOnly(date(dateSelectedByUser, userLocale()))
return true
}
Date d
if (selectDateDialog(d, "Date Selector", "Please select a date:", today, null, null))
{
print stringOf(d)
}
Thanks! exactly what I was looking for today and feeling lazy :) Sara |